<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        /* 从以下学员名单中随机选出4个学员：
                                var arr = ["罗彬","熊博文","黄鸿鹏","李茂林","陈汝威","麦子彬","王光彩","邓君","卢儒山","张境锋","蔡泽钏","周圆","郑华","温俊林","梁自立","袁国文"]；
                                学员不能重复
                                */
        let arr = ["罗彬", "熊博文", "黄鸿鹏", "李茂林", "陈汝威", "麦子彬", "王光彩", "邓君", "卢儒山", "张境锋", "蔡泽钏", "周圆", "郑华", "温俊林", "梁自立", "袁国文"];
        let new_arr = [];


        for (let i = 0; i < 4; i++) {
            let student = arr[get_random(arr.length - 1, 0)];
            if (new_arr.indexOf(student) == -1) {
                new_arr.push(student);
            } else {
                i--;
            }
        }

        function get_random(max, min) {
            return Math.floor(Math.random() * (max - min + 1) + min);
        }
        console.log(new_arr);
    </script>
</body>

</html>